<template>
	<view class="page">

		<view class="kcsj_box" v-if="list.length > 0">
			<view class="kcsj_box_item" v-for="(item,index) in list" >
				<view class="kcsj_box_item_top">
					<view class="kcsj_box_item_top_left">
						包名:{{item.work_package_title}}
					</view>
					
					<view class="kcsj_box_item_top_right" v-if="item.status == 0" @click="gotoInfo(item)">
						<view class="kcsj_box_item_top_right_btn">待处理</view>
						<u-icon name="arrow-right" color="rgb(119, 119, 119)" size="16"></u-icon>
					</view>
					
					<!-- <view class="kcsj_box_item_top_right" v-if="item.status == 1 && item.is_mode == 1" >
						<view class="kcsj_box_item_top_right_btn">待审核</view>
						<u-icon name="arrow-right" color="rgb(119, 119, 119)" size="16"></u-icon>
					</view> -->
					
					<view class="kcsj_box_item_top_right" v-if="item.status == 1" @click="gotoInfo(item)">
						<view class="kcsj_box_item_top_right_btn">待审核</view>
						<u-icon name="arrow-right" color="rgb(119, 119, 119)" size="16"></u-icon>
					</view>
					
					<view class="kcsj_box_item_top_right"  v-if="item.status == 2" >
						<view class="kcsj_box_item_top_right_btn" style="border: 1px solid rgb(100, 200, 80);color:rgb(100, 200, 80)">通过</view>
						<u-icon name="arrow-right" color="rgb(100, 200, 80)" size="16"></u-icon>
					</view>
					<view class="kcsj_box_item_top_right" v-if="item.status == 3" @click="gotoInfo(item)">
						<view class="kcsj_box_item_top_right_btn">拒绝</view>
						<u-icon name="arrow-right" color="rgb(119, 119, 119)" size="16"></u-icon>
					</view>
					
				</view>
				<view class="kcsj_box_item_top_left" style="font-size: 25rpx;line-height: 40rpx;">
					巡检方式:{{item.is_mode == 1?"现场巡检":"电话巡检"}}
				</view>
				<view class="kcsj_box_item_bottom">
					创建时间:{{item.create_time}}
				</view>
			</view>
		</view>
		<view v-else style="font-size: 25rpx;text-align: center;margin: 40rpx;">暂无新任务</view>

		<bottom c_value="3" ref="bot"></bottom>
	</view>
</template>

<script>
	import {
		api,
		apiBaseUrl,
		http
	} from '@/config/common.js'
	import bottom from '@/components/bottom.vue'
	export default {
		data() {
			return {
				 
				page: 1,
				last_page: 1,
				list: [], 
			}
		},
		components: {
			bottom
		},
		filters: {},
		mounted() {
			this.$refs.bot.getDot()
		},
		onLoad(e) {
			
		},
		onReachBottom() {
			if (this.page < this.last_page) {
				this.page = this.page + 1
				this.initList()
			} else {
				console.log('到底了')
			}
		},
		onPullDownRefresh() {
			this.page = 1
			this.list = []
			this.initList()
		},
		onShow() {
			this.page = 1
			this.list = []
			this.initList() 
			if (this.$refs.bot) {
				this.$refs.bot.getDot()
			}
		},
		onPageScroll(e) {},
		beforeDestroy() {},
		methods: {
			gotoInfo(item) {
				if (item.is_mode == 1) {
					uni.navigateTo({
						url: '/pages/xj/index?id='+item.id+"&work_package_id="+item.work_package_id
					})
				} else {
					uni.navigateTo({
						url: '/pages/xj/dh_xj?id='+item.id+"&work_package_id="+item.work_package_id
					})
				}
				
			},
			initList() {
				uni.showLoading({})
				api.post('/api/shop/tasklist', {
					page: this.page,
					type:3
				}).then(res => {

					uni.hideLoading()
					uni.stopPullDownRefresh(); //停止刷新
					let rst = res.data.data
					this.last_page = rst.last_page
					let temp_data = rst.data 
					this.list = this.list.concat(temp_data)

				}).catch(err => {
					uni.hideLoading()
				})
			},
		}
	};
</script>

<style scoped>
	.kcsj_box_item_bottom {
		font-size: 26rpx;
		margin-top: 10rpx;
	}

	.kcsj_box_item_top_right_btn {
		border: 1px solid rgb(255, 118, 10);
		color: rgb(255, 118, 10);
		font-size: 26rpx;
		border-radius: 8rpx;
		padding: 0 10rpx;
	}

	.kcsj_box_item_top_left {
		width: 80%;
		white-space: nowrap;
		/* 确保文本在一行内显示 */
		overflow: hidden;
		/* 超出容器的文本隐藏 */
		text-overflow: ellipsis;
		/* 超出部分显示省略号 */
	}

	.kcsj_box_item_top_right {
		display: flex;
		flex-direction: row;
		align-items: center;
	}

	.kcsj_box_item_top {
		display: flex;
		flex-direction: row;
		align-items: center;
		font-size: 26rpx;
		justify-content: space-between;
	}

	.kcsj_box_item {
		width: 710rpx;
		margin: 0 auto;
		border: 1px solid rgb(235, 229, 229);
		padding: 20rpx;
		margin-top: 20rpx;
		border-radius: 10rpx;
	}

	page {
		background-color: #fff;
		padding-bottom: 120rpx;
	}
</style>